<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.lavegue.model.Area" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>编辑名录信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<script type='text/javascript' src='dwr/interface/userdwr.js'></script>
     <script type='text/javascript' src='dwr/interface/areadwr.js'></script>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type='text/javascript' src='js/jquery.validate.min.js'></script>
 	<script type='text/javascript' src='js/common.js'></script>
	
	 <script type='text/javascript' src='<%=basePath %>/dwr/engine.js'></script>
	 <script type='text/javascript' src='<%=basePath %>/dwr/util.js'></script>
	
	<script type="text/javascript" src="js/PCASClass.js"></script>
	<script language="javascript" type="text/javascript" src="<%=basePath %>/date/WdatePicker.js"></script>
	<link type="text/css"  href="images/css.css"  rel="stylesheet" />
	<link href="<%=basePath%>/backStageManage/bs.css"  rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.STYLE15 {color: #F18910}
.STYLE18 {
	color: #0F45C3;
	font-size: 14px;
}
-->
</style>


<script type="text/javascript">

function checkDataVal(){
	var company = $.trim($("#company").val());  //公司名称
	var linkman = $.trim($("#linkman").val());  //联系人
	var juridicalPerson = $.trim($("#juridicalPerson").val());   //法定代表人
	var position = $.trim($("#position").val());  //职位
	var tel = $.trim($("#tel").val());  // 电话
	var mobile = $.trim($("#mobile").val());  //移动电话
	var fax = $.trim($("#fax").val()); // 传真
	var email = $.trim($("#email").val());  // 邮箱
	var yearTurnover = $.trim($("#yearTurnover").val()); // 年营业额
	var province = $.trim($("#province").val());  //地区
	var city = $.trim($("#city").val());  //城市
	var regCap = $.trim($("#regCapital").val());   //注册资本
	var intro = $.trim($("#intro").val());   //公司介绍
	$("#messageSpan").html(""); //清空消息
		if(company == ""){  //效验公司名称
			$("#errorSpan").html("&nbsp;请输入公司名称.");
			$("#company").focus();
			return false;
		}else{
			$("#errorSpan").html("");
		}
		
		if(linkman == ""){ //效验联系人
			$("#errorSpan").html("&nbsp;请输入联系人.");
			$("#linkman").focus();
			return false;
		}else{
			$("#errorSpan").html("");
		}
		if(juridicalPerson == ""){ //效验法定代表人
			$("#errorSpan").html("&nbsp;请输入法定代表人.");
			$("#juridicalPerson").focus();
			return false;
		}else{
			$("#errorSpan").html("");
		}
		if(position == ""){ //效验职位
			$("#errorSpan").html("&nbsp;请输入职位.");
			$("#position").focus();
			return false;
		}else{
			$("#errorSpan").html("");
		}
		if(tel == ""){ //效验电话
			$("#errorSpan").html("");
			//$("#errorSpan").html("&nbsp;请输入电话.");
			//$("#tel").focus();
		}else{
			if(!isValidTelPhone(tel)){
				$("#errorSpan").html("&nbsp;输入的电话格式有误.");
				$("#tel").select();
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}
		if(mobile == ""){ //效验移动电话
			$("#errorSpan").html("&nbsp;请输入移动电话.");
			$("#mobile").focus();
			return false;
		}else{
			if(!isValidMobile(mobile)){
				$("#errorSpan").html("&nbsp;输入的移动电话格式有误.");
				$("#mobile").select();
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}
		if(fax == ""){ //效验传真
			$("#errorSpan").html("");
			//$("#errorSpan").html("&nbsp;请输入传真.");
			//$("#fax").focus();
		}else{
			if(!isValidTelPhone(fax)){
				$("#errorSpan").html("&nbsp;输入的传真格式有误.");
				$("#fax").select();
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}
		
		if(email != ""){ //效验邮箱
			if(!isValidEmail(email)){
				$("#errorSpan").html("&nbsp;输入的E_Mail格式有误.");
				$("#email").select();
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}else{
			$("#errorSpan").html("");
		/*	$("#errorSpan").html("&nbsp;请输入邮箱.");
			$("#email").focus();*/
		}
		if(province == "" || province == 0){ //效验所在地区
			$("#errorSpan").html("&nbsp;请选择所在地区.");
			$("#province").focus();
			return false;
		}else{
			$("#errorSpan").html("");
		}
		
		//公司介绍
		if(intro != ""){
			if(intro.length > 1000){
				$("#errorSpan").html("公司介绍不能超过1000字符.");
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}else{
			$("#errorSpan").html("");
		//	$("#errorSpan").html("请输入公司介绍.");
		//  $("#intro").focus();
		//	return false;
		}

	return true;
}

function editBeadrollSubmit(){
	if(!checkDataVal()){
		return false;
	}else{
		//表单提交
	    $("#editBeadrollFrm").submit();
	}
}

function cancelButton(){
	$("#company").val("");  //公司名称
	$("#linkman").val("");  //联系人
	$("#juridicalPerson").val("");   //法定代表人
	$("#position").val("");  //职位
	$("#tel").val("");  // 电话
	$("#mobile").val("");  //移动电话
	$("#fax").val(""); // 传真
	$("#email").val("");  // 邮箱
	$("#yearTurnover").val(""); // 年营业额
	var provincesf = document.getElementById("province");
	var citycs = document.getElementById("city");
	provincesf.value = "请选择..."; //设置初始值
	citycs.value = "请选择..."; //设置初始值
//	$("#province").val("请选择...");  //地区
//	$("#city").val("请选择...");  //城市
	$("#regCapital").val("");   //注册资本
	$("#intro").val("");   //公司介绍

}

//省份按钮事件
function changeProvinceHandler() {
	//获取省份下拉框的值
	var province = $("#province").val();
//	alert("province=="+province);
	//如果选择了"请选择这个项" (0表示选择了这个项)
	if (province == 0) {
		//删除市和区域下拉的全部选项
		DWRUtil.removeAllOptions("city");
		DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 		
	//删除市下拉的全部选项
	DWRUtil.removeAllOptions("city");
	//根据所选择的省从后台获取相关的市
	areadwr.findAreaByParendIdAndlvType(province, <%= Area.AreaType.CITY%>, function(data){
	DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("city", data, "id", "name");   //把data数据填充到城市下拉框
	DWRUtil.removeAllOptions("area");   //清除区域的初始值
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择" }], "id", "name");
	});
	
}

//城市按钮事件
function changeCityHandler() {
	var city = $("#city").val();
	//如果选择了"请选择这个项"
	if (city == 0) {
		//删除区下拉的全部选项
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 
				
	//删除区域下拉的全部选项
	DWRUtil.removeAllOptions("area");
	//根据所选择的市从后台获取相关的区
	areadwr.findAreaByParendIdAndlvType(city, <%= Area.AreaType.AREA%>, function(data) {
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("area", data, "id", "name"); //把data数据填充到区域下拉框
	});
}

function isZiMu_Num(str) {
	//var voidChar = /[@#\$%\^&\*]+/g;
	var voidChar = /^[A-Za-z0-9_]+$/g;
	
	return voidChar.test(str);
}

/**
 * 判断是不是有效的手机号码
 * 格式正确返回true,否则false.
 */
function isValidMobile(mobile) {
    //var pattern = /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/;
    var pattern = /^((13[0-9]{1}|15[0-9]{1}|18[0-9]{1}|)+\d{8})$/;   
    return pattern.test(mobile);
}
/**
 * 判断是不是有效的电话号码
 * 格式正确返回true,否则false.
 */
function isValidTelPhone(telphone) {
    var pattern = /^((\d{3,4})|(\d{3,4}-))?\d{7,8}$/;
    return pattern.test(telphone);
}
/**
 * 判断是不是有效的email地址
 */
function isValidEmail(vEMail) {
	var regInvalid = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!regInvalid.test(vEMail)){
		return false;
	}
	return true; 
}
/**
 * 判断是不是有效的QQ
 * 格式正确返回true,否则false.
 */
function isValidQQ(qq){
	var exgQQ = /^[1-9]\d{4,11}$/;
	return exgQQ.test(qq);
}

/**
 * 判断是不是有效的邮政编码;
 * 格式正确返回true,否则false.
 */
function isValidZipcode(code) {
    var pattern = /^\d{6}$/;
    if (!pattern.test(code)) {
        return false;
    }
    return true;
}
/**
 * 判断是不是有效的汉字
 */
function checkIsChinese(str) {
    //正则表达式
    var pattern = /[^\u4E00-\u9FA5]/g;
    if (pattern.test(str)) {
        return false;
    }
    return true;
}
/**
 * 验证输入的字符是否包含@#$%^&*:|+)(!~=}{;?>`<'非法字符
 * 如果返回true为包含,false不包含非法字符
 */	
function isIllegalChar(str) {
	var voidChar = /[@#\$%\^&\*\+\?:|.!~=>`<]+/g;
	return voidChar.test(str);
}

</script>


</head>
  
<body style="margin:0px; text-align:center;" bgcolor="#ffffff">
<div id="top">
 	<!-- 头部-->
 	<%@include file="/manage/mainTop.jsp"%>
</div>
<div id="top2"></div> 
 <!-- 中间-->
<div id="main1">  
<!-- 左边-->
 <%@include file="/manage/mainLeft.jsp"%>
  <div class="mainr2"> 
<table width="789" height="539" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
  <tr>
    <td height="500" align="left" valign="top" ><table width="788" height="545" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px solid #DBDBDB; border-left:1px solid #DBDBDB; " id="a1">
      <tr>
        <td width="112" height="22" align="center" bgcolor="#FFFFFF" style="border-top:1px solid #DBDBDB; border-right:1px solid #DBDBDB;" >修改名录信息</td>
        <td width="8" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        <td width="112" align="center" background="images/line3.jpg"  style="border:1px solid #DBDBDB;"><a href="dmAction!toAddDataPage.action" class="STYLE11">添加新数据</a></td>
        
        <td width="7" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        <td width="110" align="center" background="images/line3.jpg"   style="border:1px solid #DBDBDB; "><a href="dmAction!toBatchImportDataPage.action" class="STYLE11">批量导入</a></td>
        <td width="445" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
      </tr>
<s:form name="editBeadrollFrm" id="editBeadrollFrm" action="dmAction!doEditBeadroll.action" method="post" >   
      <tr>
        <td height="522" colspan="10" align="center" valign="top" bgcolor="#FFFFFF" style="border-right:1px solid #DBDBDB;">
        
        <input type="hidden" id="bid" name="beadroll.id" value="<s:property value="#request.beadrollid" />">
        
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="4%" height="27" align="right">&nbsp;</td>
              <td width="96%">&nbsp;</td>
            </tr>
          </table>
          <table width="741" height="387" border="0" style="border:1px solid #EBEBEB;" cellpadding="0" cellspacing="0">
            <tr>
              <td width="87" height="31" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">
              <span class="STYLE1">公司名称：</span>
              </td>
              <td align="left" class="STYLE1" style="border-bottom:1px solid #EBEBEB; padding-left:10px; ">
              <input type="text" id="company" name="beadroll.company" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.company" />">
              <span class="STYLE6">*</span>
              </td>
               <td align="center" colspan="2" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
              &nbsp;<span id="messageSpan" style="color:blue"><s:property value="actionError" /></span><span id="errorSpan" style="color:red"></span>
              </td>
              
            </tr>
            <tr>
              <td width="87" height="32" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">联系人：</td>
              <td width="281" align="left" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
              	<input type="text" id="linkman" name="beadroll.linkman" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.linkman" />">
              	<span class="STYLE6">*</span>
              </td>
              <td width="105" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">法定代表人：</td>
              <td width="266" align="left" style="border-bottom:1px solid #EBEBEB;  padding-left:10px;">
              	<input type="text" id="juridicalPerson" name="beadroll.juridicalPerson" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.juridicalPerson" />">
              	<span class="STYLE6">*</span>
              </td>
            </tr>
            <tr>
              <td height="30" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">职位：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
              	<input type="text" id="position" name="beadroll.position" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.position" />">
              	<span class="STYLE6">*</span>
              </td>
              <td align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">电话：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB;  padding-left:10px;">
              	<input type="text" id="tel" name="beadroll.tel" maxlength="15" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.tel" />">
              </td>
            </tr>
            <tr>
              <td height="32" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">移动电话：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
              	<input type="text" id="mobile" name="beadroll.mobile" maxlength="11" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.mobile" />">
              	<span class="STYLE6">*</span>
              </td>
              
              <td align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">传真：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; padding-left:10px; ">
              	<input type="text" id="fax" name="beadroll.fax" maxlength="15" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.fax" />">
              </td>
            </tr>
            <tr>
              <td height="32" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">邮箱：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
              <input type="text" id="email" name="beadroll.email" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.email" />">
              </td>
              
              <td align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">年营业额：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; padding-left:10px; ">
              <input type="text" id="yearTurnover" name="beadroll.yearTurnover" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.yearTurnover" />">
              </td>
            </tr>
            <tr>
              <td height="32" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">所在地区：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB; padding-left:10px;">
	             <s:select name="beadroll.provinceArea.id" onchange="changeProvinceHandler();" id="province" style="width:35%;"
					list="provinces" headerKey="0" headerValue="请选择..."
					listValue="name" listKey="id" value="sf_id">
				</s:select>
				省
				<s:select id="city" name="beadroll.cityArea.id" headerKey="0" style="width:28%;" headerValue="请选择..."
					    listValue="name" listKey="id" list="cityList" value="cs_id">
				</s:select>
				市&nbsp;&nbsp;<span class="STYLE6">*</span>
              </td>
              <td align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">注册资本：</td>
              <td align="left" style="border-bottom:1px solid #EBEBEB; padding-left:10px; ">
              <input type="text" id="regCapital" name="beadroll.regCapital" style="width:200px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.regCapital" />">
              </td>
            </tr>
            <tr>
              <td height="32" align="right" bgcolor="#F7F7F7" style="border-bottom:1px solid #EBEBEB; border-right:1px solid #EBEBEB;">地址：</td>
              <td colspan="3" align="left" style="border-bottom:1px solid #EBEBEB; padding-left:10px;">
              <input type="text" id="address" name="beadroll.address" style="width:600px; height:20px; border:1px solid #C6C6C6; line-height:20px; color:#414141;" value="<s:property value="beadroll.address" />">
              </td>
            </tr>
            <tr>
              <td height="164" align="right" valign="top" bgcolor="#F7F7F7"  style=" border-right:1px solid #EBEBEB;line-height:23px;">公司介绍：</td>
              <td colspan="3" align="left" valign="top" style="line-height:23px; padding-left:10px; ">
				 <textarea id="intro" name="beadroll.intro" style="width:600px; height:150px; border:1px solid #C6C6C6; line-height:20px; color:#414141;"><s:property value="beadroll.intro" /></textarea>
			  </td>
            </tr>
          </table>
         <table width="358" height="91" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="91" align="center">
              <img src="images/bc.jpg" width="92" height="24" style="cursor:hand" onClick="javascript:editBeadrollSubmit();">&nbsp;&nbsp;
            <%-- <img src="images/qx1.jpg" width="92" onclick="cancelButton();" style="cursor:hand" height="24">--%>
              </td>
            </tr>
          </table>
       </td>
      </tr>
</s:form>   
    </table>
    
    </td>
  </tr>
</table>
   
  </div>
 </div>
</body>
</html>
